//
//  AIVoiceChatBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/27.
//

import Foundation
public final class AIVoiceChatBean:  Codable {
    // MARK: - 属性
    public var text: String
    public var model: String
    public var stream: Bool = false
    public var voice_setting: VoiceSetting
    
    // MARK: - 初始化方法
    public init(
        content: String,
        voiceId: String? = nil,
        isSystem: Bool
    ) {
        self.text = content
        self.voice_setting = VoiceSetting(voiceId: voiceId)
        self.model = isSystem ?  configManager.getConfig().aiChatModel.getVoiceModel2() : configManager.getConfig().aiChatModel.getVoiceModel()
    }
    
    // MARK: - 语音设置嵌套类
    public final class VoiceSetting: NSObject, Codable {
        public var speed: Double
        public var pitch: Int = 0
        public var vol: Int = 1
        public private(set) var voice_id: String
        
        // MARK: 初始化方法
        public init(voiceId: String?) {
            // 从单例获取配置
            self.speed = configManager.getConfig().aiChat.aiVoiceSpeed
            
            // 语音 ID 逻辑处理
            if let validId = voiceId, !validId.isEmpty {
                self.voice_id = validId
            } else {
                self.voice_id = "female-tianmei-jingpin"
            }
            
            super.init()
        }
    }
}
